 
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	request.setAttribute("path", path);
		
%>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="">
    <link rel="shortcut icon" href="img/favicon.png">

    <title>菜单 列表</title>

   	<link href="${path}/style/def/js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
  	<link href="${path}/style/def/js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
  	<link href="${path}/style/def/js/data-tables/DT_bootstrap.css"  rel="stylesheet"  />

  	<link href="${path}/style/def/css/style.css" rel="stylesheet">
  	<link href="${path}/style/def/css/style-responsive.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="${path}/js/html5shiv.js"></script>
      <script src="${path}/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
  <section id="container" class="">
      <!--sidebar end-->
          <div class="wrapper">
              <!-- page start-->
              <div class="row">
                  <div class="col-lg-12">
                     <div class="panel">
                     	<form name="searchForm" method="post" class="form-search" action="" id="searchForm">
                          <header class="panel-heading">
                              	菜单 列表
                          </header>
                          <div class="panel-body">
                          		 <div class="form-inline pull-left">
                          		 	 <!-- 操作按钮 -->
                          		 	  <a class="btn btn-primary  btn-sm" href="${path}/jsp/menu/menu_edit.jsp">添加</a>
                          		 </div>
                          		 <div class="form-inline pull-right">
                          			  <!-- 查询条件 -->
								      <div class="form-group">
                                      	  <input type="text" name="name" class="form-control"  placeholder="请输入菜单名">
	                                  </div>
								      <div class="form-group">
                                      	  <input type="text" name="remark" class="form-control"  placeholder="请输入备注">
	                                  </div>
	                                  <button type="button" class="btn btn-success" id="searchBtn"><i class=" icon-search"></i>搜索</button>
                          		 </div>
                          </div>
                          <table id="table_menu" class="table table-striped table-advance table-hover" style="margin-bottom:0px;">
                              <thead>
                              <tr>
                                  <th rowName="name" orderName="name:DESC" title='菜单名' > 菜单名</th>
                                  <th rowName="url" orderName="url:DESC" title='路径' > 路径</th>
                                  <th rowName="remark" orderName="remark:DESC" title='备注' > 备注</th>
                                  <th rowName="parentRes" orderName="parentRes:DESC" title='父菜单' > 父菜单</th>
                                  <th rowName="sortNo" orderName="sortNo:DESC" title='序号' > 序号</th>
                                  <th width="200px"><i class=" icon-edit"></i>操作</th>
                              </tr>
                              </thead>
                              <tbody>
                           		
                              </tbody>
                          </table>
                        <jsp:include page="/jsp/portal/page.jsp" />
                          </form>
                      </div>
                  </div>
              </div>
              <!-- page end-->
          </div>
  </section>

  <!-- Placed js at the end of the document so the pages load faster -->
<script src="${path}/style/def/js/jquery-1.10.2.min.js"></script>
<script src="${path}/style/def/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="${path}/style/def/js/jquery-migrate-1.2.1.min.js"></script>
<script src="${path}/style/def/js/bootstrap.min.js"></script>
<script src="${path}/style/def/js/modernizr.min.js"></script>
<script src="${path}/style/def/js/jquery.nicescroll.js"></script> 
<!--common scripts for all pages-->
<script src="${path}/style/def/js/scripts.js"></script>

<script src="${path}/style/def/js/respond.min.js"></script>
<script src="${path}/style/authory/js/bootbox.min.js"></script> 
<script src="${path}/style/authory/js/jquery.page.js"></script>
<script src="${path}/style/authory/js/list.js"></script>
<script src="${path}/style/authory/js/list_ajax.js"></script>
<script src="${path}/style/authory/js/common-scripts.js"></script>
<script src="${path}/style/authory/js/common.js"></script>
<script src="${path}/style/authory/js/jquery.scrollTo.min.js"></script> 

<script class="include" type="text/javascript" src="${path}/style/authory/js/jquery.dcjqaccordion.2.7.js"></script>

      <script type="text/javascript" charset="utf-8">
      var parentWindow = window.parent.window;
       
      jQuery.component({
      });
      
      function deleteByPk(pk){
       bootbox.confirm({
		   message: "确认删除?", 
		   callback: function(conResult){ 
		   		if(conResult){
		   			jQuery.ajax({
			  			url : "${path}/rest/menu/countChildRes",
			  			type : "post",
			  			data : {pk:pk},
			  			success : function(countResult) {
			  				if (countResult == 0) {
			  					jQuery.ajax({
						  			url : "${path}/rest/menu/deleteByPk",
						  			type : "post",
						  			data : {pks:pk},
						  			success : function(result) {
						  				if (result == "success") {
						  					bootbox.alert( '删除成功'); 
						  					jQuery.page( options );
						  				} else {
						  					bootbox.alert( '删除失败'); 
						  				}
						  			},
						  			error : function(result) {
						  				bootbox.alert( '删除失败'); 
						  			}
						
						  		});
			  				} else {
			  					bootbox.alert( '该菜单下有子菜单，不能删除，请将子菜单删除再删除该菜单'); 
			  				}
			  			},
			  			error : function(result) {
			  				bootbox.alert( '删除失败'); 
			  			}
			
			  		});
		   			
		    	   }
		    	}
		  })  
  	}
          var operates = {
        		  isOper:true,
        		  operHtml:"<a href=\"javascript:;\" class=\"btn btn-xs btn-info\" onclick=\"javascript:window.location.href='${path}/jsp/config/cResource_detail.jsp?pk=#id#'\"><i class=\"icon-check\"></i> 详情</a>&nbsp;"
        		  +"<a href=\"javascript:;\" class=\"btn btn-xs btn-warning\" onclick=\"javascript:window.location.href='${path}/jsp/config/cResource_edit.jsp?pk=#id#'\"><i class=\"icon-edit\"></i> 修改</a>&nbsp;"
        		  +"<a href=\"javascript:;\" class=\"btn btn-xs btn-danger\" onclick=\"deleteByPk('#id#')\"><i class=\"icon-trash\"></i> 删除</a>"
          }
          var options = {
  				tableId:'table_menu',
  				url:'${path}/menuMng/list.do',
  				operates:operates,
  				formId:'searchForm',
  				searchId:'searchBtn',
  				primaryKey:'id',
  				dataItems:{
  				}
  			};
  			jQuery.page( options );

      </script>
  </body>
</html>
